package com.aster.service.manage.service.impl;

import com.aster.common.base.BaseServiceImpl;
import com.aster.common.dto.UserToken;
import com.aster.common.exception.ServiceException;
import com.aster.service.manage.dao.EnterpriseProfitRatioInfoDao;
import com.aster.service.manage.domain.TbEnterpriseProfitRatioInfo;
import com.aster.service.manage.service.EnterpriseProfitRatioInfoService;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 
 * <br>
 * <b>功能：</b>TbEnterpriseProfitRatioInfoService<br>
 */
@Service("tbEnterpriseProfitRatioInfoService")
public class  EnterpriseProfitRatioInfoServiceImpl  extends BaseServiceImpl implements EnterpriseProfitRatioInfoService {
  private final static Logger log= Logger.getLogger(EnterpriseProfitRatioInfoServiceImpl.class);
	

	@Autowired
    private EnterpriseProfitRatioInfoDao dao;

		
	public EnterpriseProfitRatioInfoDao getDao() {
		return dao;
	}

	@Override
	public void addEnterpriseProfitRatioInfo(TbEnterpriseProfitRatioInfo tbEnterpriseProfitRatioInfo, UserToken userToken) throws ServiceException {
		if (tbEnterpriseProfitRatioInfo == null){
			throw new ServiceException(10001,"参数为空");
		}
		try {
			tbEnterpriseProfitRatioInfo.setCreateTime(new Date());
			tbEnterpriseProfitRatioInfo.setUpdateTime(new Date());
			tbEnterpriseProfitRatioInfo.setCreateUserId(Integer.parseInt(userToken.getUserId()));
			tbEnterpriseProfitRatioInfo.setUpdateUserId(Integer.parseInt(userToken.getUserId()));
			tbEnterpriseProfitRatioInfo.setState(0);
			tbEnterpriseProfitRatioInfo.setDeleted(1);
			dao.add(tbEnterpriseProfitRatioInfo);

		}catch (Exception ex){
			throw new ServiceException(10000,ex.getMessage());
		}
	}

	@Override
	public <T> T queryByEnterpriseIdAndState(Object enterpriseId) {
		return dao.queryByEnterpriseIdAndState(enterpriseId);
	}


}
